export default {
    install: (Vue, option) => {
        Vue.prototype.uxtDialog = p => {
            let pages = getCurrentPages()

            // #ifdef H5
            let layout = pages[pages.length - 1].$children[0]
            // #endif

            // #ifndef H5
            let layout = pages[pages.length - 1].$vm.$children[0]
            // #endif

            // console.log(layout)
            layout.setDialog(p)
            
            return {
                alert() {
                    return new Promise((resolve, reject) => {
                        layout.showDialog('alert', resolve)
                    })
                },
                confirm() {
                    return new Promise((resolve, reject) => {
                        layout.showDialog('confirm', resolve)
                    })
                }
            }
        }
    }
}
